#!/usr/bin/env python
# encoding: utf-8
"""
@author: youfeng
@email: youfeng243@163.com
@license: Apache Licence 
@file: parse_anhui.py
@time: 2016/12/22 15:07
"""
from parse.base_object import ParseObject


class prase_object_jiangsu(ParseObject):
    def __init__(self, **kwargs):
        ParseObject.__init__(self, **kwargs)

    def get_base_info(self, url, item=None):

        base_info = {}
        try:
            # 主要人员
            keyperson_info_url = item.get('keyperson_info_url', None)

            # 分支机构
            branch_info_url = item.get('branch_info_url', None)

            # 清算信息
            liquidation_info_url = item.get('liquidation_info_url', None)

            temp_url = None
            if keyperson_info_url is not None:
                temp_url = keyperson_info_url
            if branch_info_url is not None:
                temp_url = branch_info_url
            if liquidation_info_url is not None:
                temp_url = liquidation_info_url

            temp_url = temp_url if temp_url is not None else url
            temp_url = temp_url.split('?')[1]
            temp_list = temp_url.split('&')
            for item in temp_list:
                if item.find('org') != -1:
                    split_list = item.split('=')
                    base_info[split_list[0]] = split_list[1]
                elif item.find('id') != -1:
                    split_list = item.split('=')
                    base_info[split_list[0]] = split_list[1]
                elif item.find('seqId') != -1:
                    split_list = item.split('=')
                    base_info[split_list[0]] = split_list[1]
                elif item.find('regNo') != -1:
                    split_list = item.split('=')
                    base_info[split_list[0]] = split_list[1]
            return base_info
        except Exception as e:
            self.log.exception(e)
        return None
